// 引入UI组件
import CountUI from "../components/Count"

// 引入action
import { incrementAction, incrementAsync, decrementAction } from "../redux/count_actions"

// 从react-redux中引入connect方法
import { connect } from "react-redux"

// 将action通过props传递到ui组件
function mapActionToProps(state) {
  return { count: state }
}

// 将dispatch通过props传递到ui组件
function mapDispatchToProps(dispatch) {
  return {
    increment: (data) => dispatch(incrementAction(data)),
    decrement: (data) => dispatch(decrementAction(data)),
    incrementAsync: (data) => dispatch(incrementAsync(data))
  }
}


export default connect(mapActionToProps, mapDispatchToProps)(CountUI)